package br.com.projeto;

import br.com.projeto.Adapter.ClienteAdapter;
import br.com.projeto.DAO.ClienteDAO;
import br.com.projeto.VO.ClienteVO;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;

public class Listar extends ListActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		ClienteDAO dao = new ClienteDAO(getBaseContext());
		setListAdapter(new ClienteAdapter(getBaseContext(), dao.getAll()));

	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
		super.onListItemClick(l, v, position, id);
		ClienteVO vo = (ClienteVO) l.getAdapter().getItem(position);
		Toast.makeText(getBaseContext(), vo.getId().toString(),
				Toast.LENGTH_LONG).show();
		startActivity(new Intent("EdicaoCliente").putExtra("id", vo.getId()));
	}

}
